load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("//build:STRINGER.bzl", "stringer")
load("//pkg/testutils:buildutil/buildutil.bzl", "disallowed_imports_test")

go_library(
    name = "execinfra",
    srcs = [
        "base.go",
        "errors.go",
        "flow_context.go",
        "metrics.go",
        "outboxbase.go",
        "processorsbase.go",
        "readerbase.go",
        "server_config.go",
        "testutils.go",
        "utils.go",
        "version.go",
        ":gen-consumerstatus-stringer",  # keep
        ":gen-procstate-stringer",  # keep
    ],
    importpath = "github.com/cockroachdb/cockroach/pkg/sql/execinfra",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/base",
        "//pkg/cloud",
        "//pkg/col/coldata",
        "//pkg/gossip",
        "//pkg/jobs",
        "//pkg/keys",
        "//pkg/kv",
        "//pkg/kv/kvclient/kvcoord",
        "//pkg/kv/kvclient/rangecache",
        "//pkg/kv/kvpb",
        "//pkg/kv/kvserver/diskmap",
        "//pkg/kv/kvserver/kvserverbase",
        "//pkg/kv/kvserver/protectedts",
        "//pkg/multitenant",
        "//pkg/multitenant/multitenantcpu",
        "//pkg/roachpb",
        "//pkg/rpc",
        "//pkg/rpc/nodedialer",
        "//pkg/settings",
        "//pkg/settings/cluster",
        "//pkg/sql/catalog",
        "//pkg/sql/catalog/catenumpb",
        "//pkg/sql/catalog/descpb",
        "//pkg/sql/catalog/descs",
        "//pkg/sql/catalog/tabledesc",
        "//pkg/sql/catalog/typedesc",
        "//pkg/sql/evalcatalog",
        "//pkg/sql/execinfrapb",
        "//pkg/sql/pgwire/pgerror",
        "//pkg/sql/rowenc",
        "//pkg/sql/rowenc/valueside",
        "//pkg/sql/rowinfra",
        "//pkg/sql/sem/eval",
        "//pkg/sql/sem/tree",
        "//pkg/sql/sessiondata",
        "//pkg/sql/sqlliveness",
        "//pkg/sql/stats",
        "//pkg/sql/types",
        "//pkg/util/admission",
        "//pkg/util/buildutil",
        "//pkg/util/intsets",
        "//pkg/util/limit",
        "//pkg/util/log",
        "//pkg/util/log/logcrash",
        "//pkg/util/metric",
        "//pkg/util/mon",
        "//pkg/util/optional",
        "//pkg/util/retry",
        "//pkg/util/stop",
        "//pkg/util/timeutil",
        "//pkg/util/tracing",
        "//pkg/util/uuid",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_cockroachdb_pebble//vfs",
        "@com_github_cockroachdb_redact//:redact",
        "@com_github_marusama_semaphore//:semaphore",
        "@io_opentelemetry_go_otel//attribute",
        "@org_golang_google_grpc//:go_default_library",
    ],
)

go_test(
    name = "execinfra_test",
    size = "small",
    srcs = [
        "base_test.go",
        "main_test.go",
        "version_test.go",
    ],
    embed = [":execinfra"],
    deps = [
        "//pkg/security/securityassets",
        "//pkg/security/securitytest",
        "//pkg/server",
        "//pkg/sql/execinfrapb",
        "//pkg/sql/randgen",
        "//pkg/sql/rowenc",
        "//pkg/sql/sem/tree",
        "//pkg/sql/types",
        "//pkg/testutils/serverutils",
        "//pkg/testutils/testcluster",
        "//pkg/util/leaktest",
        "//pkg/util/randutil",
        "@com_github_stretchr_testify//require",
    ],
)

stringer(
    name = "gen-procstate-stringer",
    src = "processorsbase.go",
    typ = "procState",
)

stringer(
    name = "gen-consumerstatus-stringer",
    src = "base.go",
    typ = "ConsumerStatus",
)

disallowed_imports_test(
    "execinfra",
    [
        "//pkg/sql/colexec",
        "//pkg/sql/colflow",
        "//pkg/sql/flowinfra",
        "//pkg/sql/row",
        "//pkg/sql/rowexec",
        "//pkg/sql/rowflow",
    ],
)
